// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   ChartFactory.java

package org.achartengine;

import android.content.Context;
import android.content.Intent;
import org.achartengine.chart.BarChart;
import org.achartengine.chart.BubbleChart;
import org.achartengine.chart.CombinedXYChart;
import org.achartengine.chart.CubicLineChart;
import org.achartengine.chart.DialChart;
import org.achartengine.chart.DoughnutChart;
import org.achartengine.chart.LineChart;
import org.achartengine.chart.PieChart;
import org.achartengine.chart.RangeBarChart;
import org.achartengine.chart.ScatterChart;
import org.achartengine.chart.TimeChart;
import org.achartengine.model.CategorySeries;
import org.achartengine.model.MultipleCategorySeries;
import org.achartengine.model.XYMultipleSeriesDataset;
import org.achartengine.renderer.DefaultRenderer;
import org.achartengine.renderer.DialRenderer;
import org.achartengine.renderer.XYMultipleSeriesRenderer;

// Referenced classes of package org.achartengine:
//			GraphicalView, GraphicalActivity

public class ChartFactory
{

	public static final String CHART = "chart";
	public static final String TITLE = "title";

	private ChartFactory()
	{
	}

	public static final GraphicalView getLineChartView(Context context, XYMultipleSeriesDataset xymultipleseriesdataset, XYMultipleSeriesRenderer xymultipleseriesrenderer)
	{
		checkParameters(xymultipleseriesdataset, xymultipleseriesrenderer);
		LineChart linechart = new LineChart(xymultipleseriesdataset, xymultipleseriesrenderer);
		return new GraphicalView(context, linechart);
	}

	public static final GraphicalView getCubeLineChartView(Context context, XYMultipleSeriesDataset xymultipleseriesdataset, XYMultipleSeriesRenderer xymultipleseriesrenderer, float f)
	{
		checkParameters(xymultipleseriesdataset, xymultipleseriesrenderer);
		CubicLineChart cubiclinechart = new CubicLineChart(xymultipleseriesdataset, xymultipleseriesrenderer, f);
		return new GraphicalView(context, cubiclinechart);
	}

	public static final GraphicalView getScatterChartView(Context context, XYMultipleSeriesDataset xymultipleseriesdataset, XYMultipleSeriesRenderer xymultipleseriesrenderer)
	{
		checkParameters(xymultipleseriesdataset, xymultipleseriesrenderer);
		ScatterChart scatterchart = new ScatterChart(xymultipleseriesdataset, xymultipleseriesrenderer);
		return new GraphicalView(context, scatterchart);
	}

	public static final GraphicalView getBubbleChartView(Context context, XYMultipleSeriesDataset xymultipleseriesdataset, XYMultipleSeriesRenderer xymultipleseriesrenderer)
	{
		checkParameters(xymultipleseriesdataset, xymultipleseriesrenderer);
		BubbleChart bubblechart = new BubbleChart(xymultipleseriesdataset, xymultipleseriesrenderer);
		return new GraphicalView(context, bubblechart);
	}

	public static final GraphicalView getTimeChartView(Context context, XYMultipleSeriesDataset xymultipleseriesdataset, XYMultipleSeriesRenderer xymultipleseriesrenderer, String s)
	{
		checkParameters(xymultipleseriesdataset, xymultipleseriesrenderer);
		TimeChart timechart = new TimeChart(xymultipleseriesdataset, xymultipleseriesrenderer);
		timechart.setDateFormat(s);
		return new GraphicalView(context, timechart);
	}

	public static final GraphicalView getBarChartView(Context context, XYMultipleSeriesDataset xymultipleseriesdataset, XYMultipleSeriesRenderer xymultipleseriesrenderer, org.achartengine.chart.BarChart.Type type)
	{
		checkParameters(xymultipleseriesdataset, xymultipleseriesrenderer);
		BarChart barchart = new BarChart(xymultipleseriesdataset, xymultipleseriesrenderer, type);
		return new GraphicalView(context, barchart);
	}

	public static final GraphicalView getRangeBarChartView(Context context, XYMultipleSeriesDataset xymultipleseriesdataset, XYMultipleSeriesRenderer xymultipleseriesrenderer, org.achartengine.chart.BarChart.Type type)
	{
		checkParameters(xymultipleseriesdataset, xymultipleseriesrenderer);
		RangeBarChart rangebarchart = new RangeBarChart(xymultipleseriesdataset, xymultipleseriesrenderer, type);
		return new GraphicalView(context, rangebarchart);
	}

	public static final GraphicalView getCombinedXYChartView(Context context, XYMultipleSeriesDataset xymultipleseriesdataset, XYMultipleSeriesRenderer xymultipleseriesrenderer, String as[])
	{
		if (xymultipleseriesdataset == null || xymultipleseriesrenderer == null || as == null || xymultipleseriesdataset.getSeriesCount() != as.length)
		{
			throw new IllegalArgumentException("Dataset, renderer and types should be not null and the datasets series count should be equal to the types length");
		} else
		{
			checkParameters(xymultipleseriesdataset, xymultipleseriesrenderer);
			CombinedXYChart combinedxychart = new CombinedXYChart(xymultipleseriesdataset, xymultipleseriesrenderer, as);
			return new GraphicalView(context, combinedxychart);
		}
	}

	public static final GraphicalView getPieChartView(Context context, CategorySeries categoryseries, DefaultRenderer defaultrenderer)
	{
		checkParameters(categoryseries, defaultrenderer);
		PieChart piechart = new PieChart(categoryseries, defaultrenderer);
		return new GraphicalView(context, piechart);
	}

	public static final GraphicalView getDialChartView(Context context, CategorySeries categoryseries, DialRenderer dialrenderer)
	{
		checkParameters(categoryseries, dialrenderer);
		DialChart dialchart = new DialChart(categoryseries, dialrenderer);
		return new GraphicalView(context, dialchart);
	}

	public static final GraphicalView getDoughnutChartView(Context context, MultipleCategorySeries multiplecategoryseries, DefaultRenderer defaultrenderer)
	{
		checkParameters(multiplecategoryseries, defaultrenderer);
		DoughnutChart doughnutchart = new DoughnutChart(multiplecategoryseries, defaultrenderer);
		return new GraphicalView(context, doughnutchart);
	}

	public static final Intent getLineChartIntent(Context context, XYMultipleSeriesDataset xymultipleseriesdataset, XYMultipleSeriesRenderer xymultipleseriesrenderer)
	{
		return getLineChartIntent(context, xymultipleseriesdataset, xymultipleseriesrenderer, "");
	}

	public static final Intent getCubicLineChartIntent(Context context, XYMultipleSeriesDataset xymultipleseriesdataset, XYMultipleSeriesRenderer xymultipleseriesrenderer, float f)
	{
		return getCubicLineChartIntent(context, xymultipleseriesdataset, xymultipleseriesrenderer, f, "");
	}

	public static final Intent getScatterChartIntent(Context context, XYMultipleSeriesDataset xymultipleseriesdataset, XYMultipleSeriesRenderer xymultipleseriesrenderer)
	{
		return getScatterChartIntent(context, xymultipleseriesdataset, xymultipleseriesrenderer, "");
	}

	public static final Intent getBubbleChartIntent(Context context, XYMultipleSeriesDataset xymultipleseriesdataset, XYMultipleSeriesRenderer xymultipleseriesrenderer)
	{
		return getBubbleChartIntent(context, xymultipleseriesdataset, xymultipleseriesrenderer, "");
	}

	public static final Intent getTimeChartIntent(Context context, XYMultipleSeriesDataset xymultipleseriesdataset, XYMultipleSeriesRenderer xymultipleseriesrenderer, String s)
	{
		return getTimeChartIntent(context, xymultipleseriesdataset, xymultipleseriesrenderer, s, "");
	}

	public static final Intent getBarChartIntent(Context context, XYMultipleSeriesDataset xymultipleseriesdataset, XYMultipleSeriesRenderer xymultipleseriesrenderer, org.achartengine.chart.BarChart.Type type)
	{
		return getBarChartIntent(context, xymultipleseriesdataset, xymultipleseriesrenderer, type, "");
	}

	public static final Intent getLineChartIntent(Context context, XYMultipleSeriesDataset xymultipleseriesdataset, XYMultipleSeriesRenderer xymultipleseriesrenderer, String s)
	{
		checkParameters(xymultipleseriesdataset, xymultipleseriesrenderer);
		Intent intent = new Intent(context, org/achartengine/GraphicalActivity);
		LineChart linechart = new LineChart(xymultipleseriesdataset, xymultipleseriesrenderer);
		intent.putExtra("chart", linechart);
		intent.putExtra("title", s);
		return intent;
	}

	public static final Intent getCubicLineChartIntent(Context context, XYMultipleSeriesDataset xymultipleseriesdataset, XYMultipleSeriesRenderer xymultipleseriesrenderer, float f, String s)
	{
		checkParameters(xymultipleseriesdataset, xymultipleseriesrenderer);
		Intent intent = new Intent(context, org/achartengine/GraphicalActivity);
		CubicLineChart cubiclinechart = new CubicLineChart(xymultipleseriesdataset, xymultipleseriesrenderer, f);
		intent.putExtra("chart", cubiclinechart);
		intent.putExtra("title", s);
		return intent;
	}

	public static final Intent getScatterChartIntent(Context context, XYMultipleSeriesDataset xymultipleseriesdataset, XYMultipleSeriesRenderer xymultipleseriesrenderer, String s)
	{
		checkParameters(xymultipleseriesdataset, xymultipleseriesrenderer);
		Intent intent = new Intent(context, org/achartengine/GraphicalActivity);
		ScatterChart scatterchart = new ScatterChart(xymultipleseriesdataset, xymultipleseriesrenderer);
		intent.putExtra("chart", scatterchart);
		intent.putExtra("title", s);
		return intent;
	}

	public static final Intent getBubbleChartIntent(Context context, XYMultipleSeriesDataset xymultipleseriesdataset, XYMultipleSeriesRenderer xymultipleseriesrenderer, String s)
	{
		checkParameters(xymultipleseriesdataset, xymultipleseriesrenderer);
		Intent intent = new Intent(context, org/achartengine/GraphicalActivity);
		BubbleChart bubblechart = new BubbleChart(xymultipleseriesdataset, xymultipleseriesrenderer);
		intent.putExtra("chart", bubblechart);
		intent.putExtra("title", s);
		return intent;
	}

	public static final Intent getTimeChartIntent(Context context, XYMultipleSeriesDataset xymultipleseriesdataset, XYMultipleSeriesRenderer xymultipleseriesrenderer, String s, String s1)
	{
		checkParameters(xymultipleseriesdataset, xymultipleseriesrenderer);
		Intent intent = new Intent(context, org/achartengine/GraphicalActivity);
		TimeChart timechart = new TimeChart(xymultipleseriesdataset, xymultipleseriesrenderer);
		timechart.setDateFormat(s);
		intent.putExtra("chart", timechart);
		intent.putExtra("title", s1);
		return intent;
	}

	public static final Intent getBarChartIntent(Context context, XYMultipleSeriesDataset xymultipleseriesdataset, XYMultipleSeriesRenderer xymultipleseriesrenderer, org.achartengine.chart.BarChart.Type type, String s)
	{
		checkParameters(xymultipleseriesdataset, xymultipleseriesrenderer);
		Intent intent = new Intent(context, org/achartengine/GraphicalActivity);
		BarChart barchart = new BarChart(xymultipleseriesdataset, xymultipleseriesrenderer, type);
		intent.putExtra("chart", barchart);
		intent.putExtra("title", s);
		return intent;
	}

	public static final Intent getRangeBarChartIntent(Context context, XYMultipleSeriesDataset xymultipleseriesdataset, XYMultipleSeriesRenderer xymultipleseriesrenderer, org.achartengine.chart.BarChart.Type type, String s)
	{
		checkParameters(xymultipleseriesdataset, xymultipleseriesrenderer);
		Intent intent = new Intent(context, org/achartengine/GraphicalActivity);
		RangeBarChart rangebarchart = new RangeBarChart(xymultipleseriesdataset, xymultipleseriesrenderer, type);
		intent.putExtra("chart", rangebarchart);
		intent.putExtra("title", s);
		return intent;
	}

	public static final Intent getCombinedXYChartIntent(Context context, XYMultipleSeriesDataset xymultipleseriesdataset, XYMultipleSeriesRenderer xymultipleseriesrenderer, String as[], String s)
	{
		if (xymultipleseriesdataset == null || xymultipleseriesrenderer == null || as == null || xymultipleseriesdataset.getSeriesCount() != as.length)
		{
			throw new IllegalArgumentException("Datasets, renderers and types should be not null and the datasets series count should be equal to the types length");
		} else
		{
			checkParameters(xymultipleseriesdataset, xymultipleseriesrenderer);
			Intent intent = new Intent(context, org/achartengine/GraphicalActivity);
			CombinedXYChart combinedxychart = new CombinedXYChart(xymultipleseriesdataset, xymultipleseriesrenderer, as);
			intent.putExtra("chart", combinedxychart);
			intent.putExtra("title", s);
			return intent;
		}
	}

	public static final Intent getPieChartIntent(Context context, CategorySeries categoryseries, DefaultRenderer defaultrenderer, String s)
	{
		checkParameters(categoryseries, defaultrenderer);
		Intent intent = new Intent(context, org/achartengine/GraphicalActivity);
		PieChart piechart = new PieChart(categoryseries, defaultrenderer);
		intent.putExtra("chart", piechart);
		intent.putExtra("title", s);
		return intent;
	}

	public static final Intent getDoughnutChartIntent(Context context, MultipleCategorySeries multiplecategoryseries, DefaultRenderer defaultrenderer, String s)
	{
		checkParameters(multiplecategoryseries, defaultrenderer);
		Intent intent = new Intent(context, org/achartengine/GraphicalActivity);
		DoughnutChart doughnutchart = new DoughnutChart(multiplecategoryseries, defaultrenderer);
		intent.putExtra("chart", doughnutchart);
		intent.putExtra("title", s);
		return intent;
	}

	public static final Intent getDialChartIntent(Context context, CategorySeries categoryseries, DialRenderer dialrenderer, String s)
	{
		checkParameters(categoryseries, dialrenderer);
		Intent intent = new Intent(context, org/achartengine/GraphicalActivity);
		DialChart dialchart = new DialChart(categoryseries, dialrenderer);
		intent.putExtra("chart", dialchart);
		intent.putExtra("title", s);
		return intent;
	}

	private static void checkParameters(XYMultipleSeriesDataset xymultipleseriesdataset, XYMultipleSeriesRenderer xymultipleseriesrenderer)
	{
		if (xymultipleseriesdataset == null || xymultipleseriesrenderer == null || xymultipleseriesdataset.getSeriesCount() != xymultipleseriesrenderer.getSeriesRendererCount())
			throw new IllegalArgumentException("Dataset and renderer should be not null and should have the same number of series");
		else
			return;
	}

	private static void checkParameters(CategorySeries categoryseries, DefaultRenderer defaultrenderer)
	{
		if (categoryseries == null || defaultrenderer == null || categoryseries.getItemCount() != defaultrenderer.getSeriesRendererCount())
			throw new IllegalArgumentException("Dataset and renderer should be not null and the dataset number of items should be equal to the number of series renderers");
		else
			return;
	}

	private static void checkParameters(MultipleCategorySeries multiplecategoryseries, DefaultRenderer defaultrenderer)
	{
		if (multiplecategoryseries == null || defaultrenderer == null || !checkMultipleSeriesItems(multiplecategoryseries, defaultrenderer.getSeriesRendererCount()))
			throw new IllegalArgumentException("Titles and values should be not null and the dataset number of items should be equal to the number of series renderers");
		else
			return;
	}

	private static boolean checkMultipleSeriesItems(MultipleCategorySeries multiplecategoryseries, int i)
	{
		int j = multiplecategoryseries.getCategoriesCount();
		boolean flag = true;
		for (int k = 0; k < j && flag; k++)
			flag = multiplecategoryseries.getValues(k).length == multiplecategoryseries.getTitles(k).length;

		return flag;
	}
}
